﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DCSLibrary;
using Telerik.Web.UI;
using Utils.DCSControl;
using Utils.DatabaseUtils;

public partial class bai_viet_category_level_1 : System.Web.UI.UserControl
{
    dcPage page;
    NewsUI objNews = new NewsUI();
    DataSet dsNews;

    protected void Page_Load(object sender, EventArgs e)
    {
        page = (dcPage)this.Page;
        dsNews = objNews.GetByCategogyPageID(page.PageSettings.PageID);
        if (!IsPostBack)
        {
            if (page.PageSettings.HasEntry)
            {
                DataTable dt = page.PageSettings.Entry;
                grdNewsDetails.DataSource = dt;
                grdNewsDetails.DataBind();
            }
            else
            {
                BindNews();
            }
        }
    }

    protected void pagerChanging(object sender, PagePropertiesChangingEventArgs e)
    {
        pgnews.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
        BindNews();
    }

    private void BindNews()
    {
        grdNews.DataSource = dsNews.Tables[0];
        grdNews.DataBind();
    }

    protected DataTable GetOtherNews()
    {
        try
        {
            return TableLib.CreateTable(dsNews.Tables[0], "NewsID <> " + page.PageSettings.Entry.Rows[0]["NewsID"].ToString(),3);
        }
        catch (Exception e)
        {
            return null;
        }
    }
}
